﻿@using Pay.Core;
@model order_dto
@{
    ViewBag.Title = "订单详情";
    Layout = "~/Views/Shared/_MallLayout.cshtml";
    var img_url = ViewBag.img_url;
    var expressList = ViewBag.ExpressList as List<DropdownItem>;
    long curUserId = ViewBag.CurUserId;
}
<body class="page-order page-orderDetails">
    @if (Model != null) {
        <div class="">
            <div class="states">
                <div class="relative">
                    @if (Model.status == OrderStatus.WaitPay) {
                        <span class="fn36 fn-left">
                            待支付
                        </span>
                        <img class="absolute" src="~/Content/css/tokenmall/img/sta1.png" alt="">
                    } else if (Model.status == OrderStatus.WaitDelivery) {
                        <span class="fn36 fn-left">待发货</span>
                        <img class="absolute" src="~/Content/css/tokenmall/img/sta1.png" alt="">
                    } else if (Model.status == OrderStatus.Confirm) {
                        <span class="fn36 fn-left">待收货</span>
                        <img class="absolute" src="~/Content/css/tokenmall/img/sta2.png" alt="">
                    } else if (Model.status == OrderStatus.Finish) {
                        <span class="fn36 fn-left">已完成</span>
                        <img class="absolute" src="~/Content/css/tokenmall/img/sta3.png" alt="">
                    } else if (Model.status == OrderStatus.Close) {
                        <span class="fn36 fn-left">
                            已关闭
                        </span>
                        <img class="absolute" src="~/Content/css/tokenmall/img/sta4.png" alt="">
                    } else if (Model.status == OrderStatus.Delete) {
                        <span class="fn36 fn-left">
                            已删除
                        </span>
                        <img class="absolute" src="~/Content/css/tokenmall/img/sta4.png" alt="">
                    }
                </div>
            </div>
            <div class="mod-orderDetail bg-white mb10">
                <div class="block fn28 col-gray2 border">
                    <div class="mb10"><span>支付单号：</span>@Model.pay_info.pay_no</div>
                    <div class="mb10"><span>&nbsp;&nbsp;&nbsp;订单号：</span>@Model.order_no</div>
                    <div><span>订单时间：</span>@Model.order_time.ToString("yyyy-MM-dd HH:mm:ss")</div>
                </div>
                <ul class="borderTop">
                    <li>
                        @foreach (var item in Model.order_items) {
                            <div class="innerItem innerItemWhite">
                                <div class="img">
                                    @if (item.order_item_type != 6) {
                                        <img src="@(item.product.main_image_url != null ? item.product.main_image_url : img_url + item.product.first_image)" />
                                    } else {
                                        <img src="@(img_url +item.bazaar_product.main_img)" />
                                    }
                                </div>
                                <div class="text">
                                    <p class="fn28 col-gray1 tit mb15">
                                        @if (item.order_item_type != 6) {@item.product.name} else {@item.bazaar_product.product_name}
                                    </p>
                                    <div class="col-gray mb10">
                                        <span class="mr20">@item.sku_name</span>
                                        @*<span class="">XL</span>*@
                                    </div>
                                    <div class="price">
                                        @if (item.unit_price > 0) {
                                            <em class="fn22">￥</em>
                                            <span class="fn28 itemPrice">@item.unit_price.ToString("0.##")</span>
                                        }
                                        @if (item.unit_price > 0 && item.red_drill > 0) {
                                            <em class="fn22">+</em>
                                        }
                                        @if (item.red_drill > 0) {
                                            <span class="fn28 itemPrice">@item.red_drill.ToString("0.######")</span>
                                            <em class="fn22">红钻</em>
                                        }
                                        <span class="fn-right quantity">
                                            <em class="col-gray">×</em> <em class="j-quantity">@item.quantity</em>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        }
                        <div class="block">
                            <span class="fn-right fn26">
                                <em class="mr20">共@(Model.order_items.Sum(o => o.quantity))件商品</em>
                                <em>支付金额：</em>
                                @if (Model.pay_amount > 0) {
                                    <em class="fn24">￥</em>
                                    <em class="fn30">@(Model.pay_amount.ToString("0.##"))</em>
                                }
                                @if (Model.pay_amount > 0 && Model.red_drill > 0) {
                                    <em class="fn24">+</em>
                                }
                                @if (Model.red_drill > 0) {
                                    <em class="fn30">@(Model.red_drill.ToString("0.######"))</em>
                                    <em class="fn24">红钻</em>
                                }
                            </span>
                        </div>
                    </li>
                </ul>
            </div>

            <div class="mod-orderDetail">
                <ul>
                    <li>
                        <div class="block fn28">
                            <p class="fn-clear mb10">
                                买家信息：@Model.shipping.ship_to
                                <a class="ui-btn ui-btn-border w140 fn-right copy_btn" href="javascript:void(0);"
                                      data-clipboard-text="@Model.shipping.ship_to @Model.shipping.phone  @Model.shipping.region_name @Model.shipping.address">复制</a>
                            </p>
                            <p>
                                <span class="mr20">@Model.shipping.ship_to</span>
                                @Model.shipping.phone
                            </p>
                            <p>@Model.shipping.region_name  @Model.shipping.address</p>
                        </div>
                        <div class="block fn28 borderTop message">
                            <span class="lable">买家留言</span>
                            <div class="hidden">
                                @Model.remark
                            </div>
                        </div>
                        <div class="block fn28 borderTop message">
                            <span class="lable">物流信息</span>
                            <div class="hidden">
                                @Model.shipping.express_company_name
                                <br>
                                @Model.shipping.ship_order_number
                            </div>
                        </div>
                        @if (Model.status == OrderStatus.WaitDelivery) {
                            <div class="block borderTop flex">
                                <br>
                                <a class="ui-btn ui-btn-buy shadow flex-1" href="/MyOrder/SellerDelivery?order_id=@Model.id">发货</a>
                            </div>
                        }
                    </li>
                </ul>
            </div>

            @if (Model.status == OrderStatus.Confirm && Model.merchant_id == curUserId) {
                if (Model.shipping.shipping_time != null
                           && ((DateTime)Model.shipping.shipping_time).AddDays(5) < DateTime.Now
                           && ((DateTime)Model.shipping.shipping_time).AddDays(12) > DateTime.Now) {
                    <div class="lt-block fn-center">
                        <div class="fn26 col-gray count_down mb15">
                            <em class="day_num"></em><em class="hour_num"></em><em class="min_num"></em><em class="sec_num"></em>
                            后自动收货
                        </div>
                    </div>
                }
            }
        </div>
    }
</body>

<script src="~/Scripts/clipboard.min.js"></script>
<script type="text/javascript">
    $(function () {
        var clipboard = new ClipboardJS('.copy_btn');
        clipboard.on('success', function (e) {
            layer.msg("复制成功");
            e.clearSelection();
        });

        clipboard.on('error', function (e) {
            console.log(e);
        });
    })
</script>
<script src="~/Scripts/tokenmall/countDown.js"></script>
<script type="text/javascript">
    $(function () {
        if ($(".count_down") == undefined || $(".count_down") == null || $(".count_down").length == 0)
            return;
            $(".count_down").countDown({
                startTimeStr: "@(Model.shipping.shipping_time ?? DateTime.Now)",//开始时间
                endTimeStr: " @((Model.shipping.shipping_time ?? DateTime.Now.AddDays(-12)).AddDays(12))",//结束时间
                daySelector: ".day_num",
                hourSelector: ".hour_num",
                minSelector: ".min_num",
                secSelector: ".sec_num"
             });
             $(".count_down").afterAction();
    });

</script>
